import ActionTypes from '../config/ActionTypes';
import ActionCodes from '../config/ActionCodes';
import { postFetch, getFetch } from '../utils/network/request/HttpExtension.js';
import { createAction } from 'redux-actions';
import Session from '../utils/SessionUtils';
import { AsyncStorage } from 'react-native';

export function GetArticleForMobileByID(articleId) {
	return dispatch => {
		dispatch({ type: ActionTypes.NEWSDETAIL + ActionTypes.FETCH_LOADING_SUFFIX });

        let param = { ID: articleId };
        postFetch(ActionCodes.newDetail, param)
			.then(res => {
                var item = {}
                if (res && JSON.stringify(res).indexOf('Public.E') < 0){
                    item = res
                }
				dispatch({
                    type: ActionTypes.NEWSDETAIL + ActionTypes.FETCH_SUCCESS_SUFFIX,
                    item: item
				});
			})
			.catch(err => {
				alert(err);
				dispatch({ type: ActionTypes.NEWSDETAIL + ActionTypes.FETCH_ERROR_SUFFIX });
			});
	};
}
